package com.dongdongmovie.controller;

import com.dongdongmovie.pojo.TType;
import com.dongdongmovie.service.TType_Service;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("TType")
public class TType_Controller {
    
    //注入service
    @DubboReference
    private TType_Service tType_service;

    //跳转到show
    @RequestMapping("tzshow")
    public String tzshow(){
        return "TType/show";
    }

    //跳转到add
    @RequestMapping("tzadd")
    public String tzadd(){
        return "TType/add";
    }

    //跳转到update
    @RequestMapping("tzupdate")
    public String tzupdate(Integer id, Model model){
        TType tCharnnel = tType_service.showbyId(id);
        model.addAttribute("TType",tCharnnel);
        return "TType/update";
    }

    //查询数据
    @ResponseBody
    @RequestMapping("show")
    public List<TType> show(){
        return tType_service.show();
    }

    //添加数据
    @ResponseBody
    @RequestMapping("add")
    public int add(TType tCharnnel){
        return tType_service.add(tCharnnel);
    }

    //修改数据
    @ResponseBody
    @RequestMapping("update")
    public int update(TType tCharnnel){
        return tType_service.update(tCharnnel);
    }

    //删除数据
    @ResponseBody
    @RequestMapping("delete")
    public int delete(Integer id){
        return tType_service.delete(id);
    }
}
